package com.liveneo.adapter.outinterface.util;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
  * @Description: spring 工具类
  * @author liveneo-shuqw
  * @date 2016年10月13日 上午9:42:37
  * Copyright: Copyright (c) 2016 
  * Company: 北京朗泰
  * @version 3.0
  */
public class SpringConfigTool implements ApplicationContextAware {

	private static ApplicationContext ac = null;
	private static SpringConfigTool springConfigTool = null;

	public synchronized static SpringConfigTool init() {
		if (springConfigTool == null) {
			springConfigTool = new SpringConfigTool();
		}
		return springConfigTool;
	}

	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		ac = applicationContext;
	}

	public synchronized static Object getBean(String beanName) {
		return ac.getBean(beanName);
	}
}